<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>


<form:form commandName="model" cssClass="validate" id="problemForm"
	action="problem/problem/save">
	<input name="id" type="hidden" value="${model.id }">

	<div class="header">
		<h3>问题信息</h3>
	</div>
	<table class="form-table">
		<tr>

			<td class="td1">请求人：</td>
			<td class="td2"><form:hidden path="requester" /> <isperp:departmentUser
					displayValue="${model.requesterName }" valueControlId="requester"
					id="requesterName" name="requesterName"
					displayValueCssClass="required"></isperp:departmentUser></td>
			<td class="td1">请求日期：</td>
			<td class="td2"><input id="req" name="requestDate"
				value="${model.requestDate }" class="required" type="datetime">
			</td>

		</tr>
		<tr>
			<td class="td1">分类：</td>
			<td class="td2"><form:hidden path="probCategoryId" /> <isperp:treeSelector
					url="incident/category/getTree" id="probCategorySelector"
					name="probCategoryName" displayValue="${model.probCategoryName }"
					valueControlId="probCategoryId" displayValueCssClass="required"></isperp:treeSelector>
			</td>

			<td class="td1">紧急度：</td>
			<td class="td2"><isperp:dictListSelector id="urgencyName"
					items="${urgencys }" name="urgencyName" hasEmptyValue="false"
					selectedValue="${model.urgencyName }"
					onchangeFunc="resetPriorityName()">
				</isperp:dictListSelector></td>

		</tr>

		<tr>

			<td class="td1">影响度：</td>
			<td class="td2"><isperp:dictListSelector id="effectName"
					items="${effects }" name="effectName" hasEmptyValue="false"
					selectedValue="${model.effectName }"
					onchangeFunc="resetPriorityName()">
				</isperp:dictListSelector>
			</td>
			<td class="td1">优先级：</td>
			<td class="td2"><isperp:dictListSelector id="priorityName"
					otherAttribute="readonly='readonly'" items="${prioritys }"
					name="priorityName" hasEmptyValue="false"
					selectedValue="${model.priorityName }">
				</isperp:dictListSelector>
			</td>
		</tr>
		<tr>
			<td class="td1">问题来源：</td>
			<td class="td2" colspan="3"><isperp:dictSelector id="source"
					typeCode="PROBLEM_SOURCE" name="source" hasEmptyValue="false"
					selectedValue="${model.source }">
				</isperp:dictSelector></td>
		<tr>
		<tr>
			<td class="td1">选择项目：</td>
			<td class="td2" colspan="3"><form:select path="projectId"
					cssClass="required search" items="${projects }" itemValue="id"
					itemLabel="name" data-width="310px" /></td>
		<tr>
		<tr>
			<td class="td1">问题标题：</td>
			<td class="td2" colspan="3"><input id="problemTitle"
				name="title" value="${model.title }" class="required" type="text"
				maxlength="200" style="width:80%"></td>
		</tr>
		<tr>
			<td class="td1">问题描述：</td>
			<td class="td2" colspan="3"><textarea id="problemDescription"
					class="required" name="description">${model.description }</textarea>
			</td>
		</tr>
		<tr>
			<td class="td1">附件：</td>
			<td class="td2" colspan="3"><isperp:uploader
					sourceId="${model.id }" id="problemFiles"></isperp:uploader></td>
		</tr>
		 <tr id="assetTr">
			<td class="td1">关联资产：</td>
			<td class="td2" colspan="3"><isperp:ciUseRelation
					relationId="${model.id }" viewOnly="false"
					relationType="provblemProcess"></isperp:ciUseRelation></td>
		</tr> 

	</table>

	<%-- <div class="header">
		<h3>指定问题识别人</h3>
	</div>
	<table class="form-table">
		<tr>
			<td class="td1">问题识别人：</td>
			<td class="td2"><form:hidden path="problemNextActioner" /> <isperp:departmentUser
					displayValue="${model.problemNextActionerName }" idFieldName="name"
					valueControlId="problemNextActioner" id="problemNextActionerName"
					name="problemNextActionerName" displayValueCssClass="required"></isperp:departmentUser>
			</td>
		</tr>
	</table> --%>
	<div class="header">
		<h3>关联流程</h3>
	</div>
	<isperp:processRelation businessKey="${detail.id }" readonly="false"
		processKey="problemProcess" projectIdControl="projectId"></isperp:processRelation>

</form:form>


<isperp:buttonList>
	<isperp:processButtons processKey="problemProcess" formId="problemForm"
		processId="${model.processId }" businessKey="${model.id }"></isperp:processButtons>
</isperp:buttonList>


<script type="text/javascript">
	function resetPriorityName() {
		var $urgencyName = $("#urgencyName option:selected"), urgencyNameCode = parseInt($urgencyName.data("code"));
		var $effectName = $("#effectName option:selected"), effectNameCode = parseInt($effectName.data("code"));

		var ueVal = urgencyNameCode + effectNameCode;

		var $priorityName = $("#priorityName"), $priorityNameOptions = $("#priorityName option");

		for ( var i = 0; i < $priorityNameOptions.length; i++) {
			var $item = $($priorityNameOptions[i]), code = parseInt($item.data("code"));

			if (ueVal >= code) {
				$priorityName.val($item.val());
				$("#priorityName").trigger("chosen:updated");
				return;
			}
		}

	}
</script>


